package com.hice.demo.java.concurrent;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

/**
 * 链阻塞队列 LinkedBlockingQueue
 * @author hyson
 * @create 2017-03-13 11:22
 */
public class LinkedBlockingQueueExample {

    public static void main(String[] args) {
        BlockingQueue<String> unbounded = new LinkedBlockingQueue<>();
        //BlockingQueue<String> bounded = new LinkedBlockingQueue<>(1024);

        try {
            unbounded.put("Value");
            unbounded.put("Value2");
            String value = unbounded.take();
            System.out.println("输出:" + value);
            Thread.sleep(1000);
            String value2 = unbounded.take();
            System.out.println("输出:" + value2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }

}
